package com.chag.app.home.controller;

import com.chag.biz.userbase.dto.UserDTO;
import com.chag.biz.userbase.dto.UserSearchDTO;
import com.chag.biz.userbase.service.IMessageService;
import com.chag.biz.userbase.service.IUserService;
import com.chag.framework.common.ServiceResult;
import com.taobao.api.response.AlibabaAliqinFcSmsNumSendResponse;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;


@Controller
@RequestMapping(value = "api")
public class APIController {
    //日志组件
    private Logger logger = Logger.getLogger(getClass());
    @Resource
    private IUserService userService;

    @Resource
    private IMessageService messageService;

    /**
     * 获取用户列表
     *
     * @param searchDTO 查询条件
     * @return 用户列表
     */
    @ResponseBody
    @RequestMapping(value = "userList")
    public Object userList(UserSearchDTO searchDTO) {
        logger.info("#################" + getClass());

        ServiceResult<AlibabaAliqinFcSmsNumSendResponse> alibabaAliqinFcSmsNumSendResponseServiceResult = messageService.sendMessage();

        ServiceResult<List<UserDTO>> userRet = userService.getUserListBySearchDTO(searchDTO);

        return userRet;
    }
}
